 var $ = require('../../lib/jquery');
 var util = require('./common/util');
 var nav = require('./common/nav');
 var template = require('../tpl/template');
 var _header = require('./common/header');
 var _nav = new nav();
 var header = new _header();
 window.$ = $;
 var minheight = {
   init:function(data) {
     var _this = this;
     var windowH = window.innerHeight;
     var header = $('header').height();
     var footerh = $('footer').height();
     var navH = $('nav').height();
     var js_tips_wrap = $('.js_tips_wrap').height();
     var n = windowH - header - footerh - navH - js_tips_wrap;
     var _this=this;
     if (n > 0) {
       $('.js_banner').css('min-height', n + 'px');
     }
     $('.js_more').on('click', function() {
       window.location.href = './zixun.html'
     })
     $('.js_more_news').on('click', function() {
       _this.getmorezhi();
       $('.js_message').removeClass('hide');
     })
     $('.js_cancel').on('click', function() {
       $('.js_message').addClass('hide');
     })
     this.getzixun(1);  
     this.getzixun(0);
     $('.js_tab1').on('click', '.js_xq', function () {
       location.href= $(this).data().link;
     })
     $('.js_tab2').on('click', '.js_xq', function () {
        $('.js_message').removeClass('hide');
        _this.getmorezhi();

    })

   },
   getzixun: function (type1){
     util.fetch('api/notice/list', {
       type: type1,
       currentTime: this.formatDateTime(),
       size: 4,
       from: "",
       search: '',
     }).then(function(res) {
       if (type1 == 0) {
         var tpl = template('index_new', {
           data: res.data
         });
         $('.js_news').html(tpl)
       } else {
         var t = template('index_new', {
           data: res.data
         });
         $('.js_zi').html(t);
       }
     })
   },
   getmorezhi: function (data) {
     util.fetch('api/notice/list', {
       type: 0,
       currentTime: this.formatDateTime(),
       size: 50,
       from: "",
       search: '',
     }).then(function(res) {
       var n = template('morezhi', {
         data: res.data
       });
       $('.js_blocks').html(n);
     })
   },
   formatDateTime: function (data) {
     var date = new Date();
     var y = date.getFullYear();
     var m = date.getMonth() + 1;
     m = m < 10 ? ('0' + m) : m;
     var d = date.getDate();
     d = d < 10 ? ('0' + d) : d;
     var h = date.getHours();
     h = h < 10 ? ('0' + h) : h;
     var minute = date.getMinutes();
     var second = date.getSeconds();
     minute = minute < 10 ? ('0' + minute) : minute;
     second = second < 10 ? ('0' + second) : second;
     return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
   }



 }

 minheight.init();